package com.huya.controller.admin;

import com.huya.common.result.PageResult;
import com.huya.common.result.Result;
import com.huya.pojo.dto.ReportPageQueryDTO;
import com.huya.pojo.dto.ReportProcessingDTO;
import com.huya.pojo.vo.ReportVO;
import com.huya.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/report")
@Slf4j
public class ReportController {
    @Autowired
    private ReportService reportService;
    /**
     * 分页查询举报信息
     * @param reportPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result <PageResult> page(ReportPageQueryDTO reportPageQueryDTO){
        log.info("reportPageQueryDTO: {}", reportPageQueryDTO);
        PageResult pageResult = reportService.pageQuery(reportPageQueryDTO);
        return Result.success(pageResult);
    }
    /**
     * 根据id查询举报信详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<ReportVO> get(@PathVariable Long id){
        log.info("get: {}", id);
        ReportVO reportVO = reportService.getById(id);
        return Result.success(reportVO);
    }
    /**
     * 处理举报信息
     * @param reportProcessingDTO
     * @return
     */
    @PostMapping("/processing")
    public Result processing(@RequestBody ReportProcessingDTO reportProcessingDTO){
        reportService.processing(reportProcessingDTO);
        return Result.success();
    }

    /**
     * 完成举报信
     * @param id
     * @return
     */
    @PostMapping("/finish/{id}")
    public Result finish(@PathVariable Long id){
        reportService.finish(id);
        return Result.success();
    }
}
